#include "main.h"
#include "wwdg.h"


void WWDG_Config(uint32_t prescaler, uint16_t window_value, uint16_t counter_value)
{
	/* Enable WWDG clock */
	RCC_APB1_Peripheral_Clock_Enable(RCC_APB1_PERIPH_WWDG);
	
	/* WWDG clock counter = (PCLK1(32MHz)/4096)/prescaler */
	WWDG_Prescaler_Division_Set(prescaler);
	
	/* Set Window value to window_value; WWDG counter should be refreshed only when the counter
     is below window_value and greater than 0x40 otherwise a reset will be generated */
	WWDG_Window_Value_Set(window_value);
	
	/* Set the value of the down counter */
	WWDG_Counter_Value_Set(counter_value);
	
	/* Enable WWDG and set counter value to counter_value */
	WWDG_Enable(counter_value);
}

/**
 *\*\name    WWDG_Feed.
 *\*\fun     Feed the dog.
 *\*\param  counter_value :
 *\*\          -0x40 ~ 0x3FFF
 *\*\return  none
**/
void WWDG_Feed(uint16_t counter_value)
{
	WWDG_Counter_Value_Set(counter_value);
}
